package com.star.common.oss.factory;


import com.star.common.oss.service.OssClient;

import java.util.Map;
import java.util.Objects;

/**
 * oss生产工厂
 *
 * @author zhouhengzhe #公众号：小白的Java进阶之路
 * @version 1.0
 * @date 2023/6/27 15:50
 */
public class OssFactory {

    private final Map<String, OssClient> ossClientMap;

    public OssFactory(Map<String, OssClient> ossClientMap) {
        this.ossClientMap = ossClientMap;
    }

    /**
     * 构建Oss服务端
     *
     * @param provider 短信类型，
     *                 See Also: com.changzhi.middleware.sms.enums.SmsTypeEnum
     * @return
     */
    public OssClient buildOssClient(String provider) {
        OssClient ossClient = ossClientMap.get(provider);
        if (Objects.isNull(ossClient)) {
            throw new RuntimeException("当前的【" + provider + "】的对应的yml配置为空，或者【" + provider + "】类型不存在");
        }
        return ossClient;
    }
}
